<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .prize{
            display: inline-block;
            width: 100px;
            height: 80px;
            line-height: 80px;
            text-align: center;
            margin-top: 90px;
            margin-left: 100px;
            border: 1px solid black;
        }
        #bt{
            display: inline-block;
            height: 100px;
            width: 100px;
            position: absolute;
            bottom: 10px;
            left: 48vw;
        }
    </style>
</head>
<body>
    <button id="bt" onclick="action()">开始</button>
    <div id="kj">

    </div>
    <script>
        var kj = document.getElementById('kj');
        //奖池
        var prizeArr = ['iphone 14','大棉袄','键盘','鼠标','金坷垃','纯悦','海之言','陈佳伦','js基础','javaee','thinkphp','c++']
        var prize = prizeArr[0];
        var isBegin = false;
        var bt = document.getElementById('bt');
        function action(){
            if(isBegin){
                isBegin = false;
                bt.innerText = "开始";
                alert('您抽中了'+prize);
            }else{
                isBegin = true;
                bt.innerText = "停止";
            }
        }
        function prizeToHtml(){
            kj.innerHTML = "";
            prizeArr.forEach(element => {
                if(element == prize){
                    kj.innerHTML += "<div class='prize' style='color: white;background-color: black;'>"+element+"</div>";
                }else{
                    kj.innerHTML += "<div class='prize'>"+element+"</div>";
                }
            });
        }
        prizeToHtml();
        
        setInterval(() => {
            if(isBegin){
                prize = prizeArr[Math.floor(Math.random()*prizeArr.length)];
                prizeToHtml();
            }
        }, 100);

    </script>
</body>
</html>